<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


if(!function_exists('filtersort'))
{
	function filtersort($url, $title, $order, $direction = 'asc', $selected = 0, $class = 'linkAjax')
	{
		$direction = strtolower($direction);
		$orderIcons = array('icon-arrow-up-3', 'icon-arrow-down-3');
		$index = (int) ($direction == 'desc');

		if ($order != $selected)
		{
			$direction = 'desc';
		}
		else
		{
			$direction = ($direction == 'desc') ? 'asc' : 'desc';
		}

		$orderIcon = $orderIcons[$index];
		if($class)
			$class = ' '.$class;

		$html = '';
		$html = '<a href="'.$url.'?ordering='.$order.'&direction='.$direction.'" class="hasTip'.$class.'" data-order="'.$order.'" data-direction="'.strtolower($direction).'" title="'.lang('sort_by_this_column').'">';
		if (!empty($title))
			$html .= ' '.$title;
		if ($order == $selected)
			$html .= '<i class="'.$orderIcon.'"></i>';
		$html .= '</a>';

		return $html;
	}
}